<?php
/**
 * This is a placeholder class.
 * Create the same file in app/app_controller.php
 *
 * Add your application-wide methods in the class below, your controllers
 * will inherit them.
 *
 * @package		cake
 * @subpackage	cake.cake
 */

class AppController extends Controller 
{
	var $helpers = array( 'Html' , 'Javascript' , 'Rule' , 'Print' , 'Pagination' );
	var $components = array( 'Pagination' );
	
	function beforeFilter()
	{
		$logado = $this->Session->check( 'co_user' );

		if( !$logado && !strstr( $this->here , '/login' ) )
		{
			$this->redirect( '/pages/login/' );
			die();
		}
		
		$this->set( 'logado' , $logado );
		$this->set( 'co_user' , $this->Session->read( 'co_user' ) );
		$this->set( 'co_perfil' , $this->Session->read( 'co_perfil' ) );
		$this->set( 'login_usuario' , $this->Session->read( 'login_usuario' ) );

	}

	function beforeRender()
	{
		
		if( $this->Session->check( 'message' ) )
		{
			$this->set( 'message' , $this->Session->read( 'message' ) );
			$this->Session->del( 'message' );
		}
		$this->set( 'class' , 'tab1' );
	}

	function flash( $message , $url) 
	{
		$this->Session->write( 'message', $message );
		
		$this->redirect($url);
	}
}
?>